/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package aptech.semester.code.data;

import aptech.semester.code.conn.MyLib;
import aptech.semester.code.entity.EducationEntity;
import aptech.semester.code.entity.SpecializedEntity;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author vi
 */
public class SpecializedList {
    private String QUERY_ALL_SPECIALIZED = "SELECT * FROM SPECIALIZE";
    
    public List<SpecializedEntity> getAllSpecialized() {
        List<SpecializedEntity> listSpecialized = new ArrayList<>();
        
        try {          
            Connection cn = MyLib.getCN();
            if(cn != null) {
                Statement st = cn.createStatement();
                 ResultSet rs = st.executeQuery(QUERY_ALL_SPECIALIZED);
                 
                while(rs.next()) {
                    SpecializedEntity specialized = new SpecializedEntity();
                    specialized.setSpecializedId(rs.getInt("ID"));
                    specialized.setSpecializedName(rs.getString("SPECIALIZE_NAME"));                    
                    specialized.setDescription(rs.getString("DESCRIPTION"));
                     
                    listSpecialized.add(specialized);
                }
                rs.close();
                cn.close();
            }           
        } catch (Exception e) {
            e.printStackTrace();
        } 
        return listSpecialized;
    }
}
